package cn.itcast.service.cargo.impl;

import cn.hutool.core.util.IdUtil;
import cn.itcast.dao.cargo.FinanceDao;
import cn.itcast.domain.cargo.Finance;
import cn.itcast.domain.cargo.FinanceExample;
import cn.itcast.domain.cargo.Packing;
import cn.itcast.domain.cargo.Shipping;
import cn.itcast.service.cargo.FinanceService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Date;
import java.util.List;
@Service
public class FinanceServiceImpl implements FinanceService {
    @Autowired
    private FinanceDao financeDao;
    @Override
    public int deleteByPrimaryKey(String financeId) {
        return financeDao.deleteByPrimaryKey(financeId);
    }

    @Override
    public int insert(Finance record) {
        return 0;
    }

    @Override
    public int insertSelective(Finance record) {
        return 0;
    }

    @Override
    public List<Finance> selectByExample(FinanceExample example) {
        return null;
    }

    @Override
    public Finance selectByPrimaryKey(String financeId) {
        return financeDao.selectByPrimaryKey(financeId);
    }

    @Override
    public int updateByPrimaryKeySelective(Finance record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Finance record) {
        return 0;
    }

    @Override
    public void save(Finance finance, String id) {
        finance.setFinanceId(IdUtil.simpleUUID());
        finance.setState(0);
        finance.setInputDate(new Date());
        finance.setInvoiceId(id);
        financeDao.insertSelective(finance);
    }

    @Override
    public void update(Finance finance) {
        financeDao.updateByPrimaryKeySelective(finance);
    }

    @Override
    public PageInfo findByPage(Integer pageNum, Integer pageSize, FinanceExample financeExample) {
        PageHelper.startPage(pageNum,pageSize);
        List<Finance> list = financeDao.selectByExample(financeExample);
        return new PageInfo(list);
    }
}
